package com.yanfan.ccapi.service.impl;

import com.yanfan.ccapi.service.ICcapiActionMappingService;
import com.yanfan.ccapicode.dao.ActionMappingRepository;
import com.yanfan.ccapicode.dao.entity.ActionMappingDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;

/**
 * 操作技能映射Service业务层处理
 *
 * @author kerwincui
 * @date 2025-06-29
 */
@Service
public class CcapiActionMappingServiceImpl implements ICcapiActionMappingService {

    @Autowired
    private ActionMappingRepository actionMappingRepository;

    /**
     * 查询操作技能映射
     *
     * @param id 操作技能映射主键
     * @return 操作技能映射
     */
    @Override
    public ActionMappingDO selectActionMappingById(Long id) {
        return actionMappingRepository.selectCcapiActionMappingById(id);
    }

    /**
     * 查询操作技能映射列表
     *
     * @param bean 操作技能映射
     * @return 操作技能映射
     */
    @Override
    public List<ActionMappingDO> selectActionMappingList(ActionMappingDO bean) {
        return actionMappingRepository.selectCcapiActionMappingList(bean);
    }

    /**
     * 新增操作技能映射
     *
     * @param bean 操作技能映射
     * @return 结果
     */
    @Override
    public boolean insertActionMapping(ActionMappingDO bean) {
        return actionMappingRepository.insertOrUpdate(bean);
    }

    /**
     * 修改操作技能映射
     *
     * @param bean 操作技能映射
     * @return 结果
     */
    @Override
    public boolean updateActionMapping(ActionMappingDO bean) {
        bean.setUpdateTime(LocalDateTime.now());
        return actionMappingRepository.insertOrUpdate(bean);
    }

    /**
     * 批量删除操作技能映射
     *
     * @param ids 需要删除的操作技能映射主键
     * @return 结果
     */
    @Override
    public boolean deleteActionMappingByIds(Long[] ids) {
        return actionMappingRepository.deleteByIds(Arrays.asList(ids));
    }

    /**
     * 删除操作技能映射信息
     *
     * @param id 操作技能映射主键
     * @return 结果
     */
    @Override
    public boolean deleteActionMappingById(Long id) {
        return actionMappingRepository.deleteById(id);
    }
}
